package test31;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-04-24
 * Time: 13:33
 */
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String str = null;
        while ((str = br.readLine()) != null && !str.equals("")) {
            int year = Integer.parseInt(str);
            bw.write(year + "-01-01" + "\n");
            int month = 13;
            year--;
            int count = 0;
            for (int day = 1; day < 32; day++) {
                int w = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 +
                        year / 400) % 7 + 1;
                if (w == 1) {
                    count++;
                }
                if (count == 3) {
                    bw.write(year + 1 + "-01-" + day + "\n");
                    break;
                }
            }
            count = 0;
            month = 14;
            for (int day = 1; day < 29; day++) {
                int w = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 +
                        year / 400) % 7 + 1;
                if (w == 1) {
                    count++;
                }
                if (count == 3) {
                    bw.write(year + 1 + "-02-" + day + "\n");
                    break;
                }
            }
            count = 0;
            month = 5;
            year++;
            for (int day = 31; day > 0; day--) {
                int w = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 +
                        year / 400) % 7 + 1;
                if (w == 1) {
                    count++;
                }
                if (count == 1) {
                    bw.write(year + "-05-" + day + "\n");
                    break;
                }
            }
            bw.write(year + "-07-04" + "\n");
            count = 0;
            month = 9;
            for (int day = 1; day < 31; day++) {
                int w = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 +
                        year / 400) % 7 + 1;
                if (w == 1) {
                    count++;
                }
                if (count == 1) {
                    bw.write(year + "-09-0" + day + "\n");
                    break;
                }
            }
            count = 0;
            month = 11;
            for (int day = 1; day < 31; day++) {
                int w = (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 +
                        year / 400) % 7 + 1;
                if (w == 4) {
                    count++;
                }
                if (count == 4) {
                    bw.write(year + "-11-" + day + "\n");
                    break;
                }
            }
            bw.write(year + "-12-25" + "\n");
            bw.write("\n");
            bw.flush();
        }
    }
}
